function ccR_Shaman_1()
	if ccrPlayerLevel() == 90 then Shaman_Elemental_90v2() end
end

local function HasActiveTotem()
  local active = false
  for i = 1, 4 do
    active = active or GetTotemInfo(i)
  end
  return active
end

function Shaman_Elemental_90v2()
	ccRS.Auto_Target = false
	ccRS.Auto_Facing = false
	
	-- Conductivity
	local vTalent = {GetTalentInfo(15)}
	local vGotConductivity = false
	if vTalent[6] == true then vGotConductivity = true else vGotConductivity = false end
	----------------
	-- Totemic Persistance
	local vTalent = {GetTalentInfo(8)}
	local vGotPersistance = false
	if vTalent[6] == true then vGotPersistance = true else vGotPersistance = false end
	----------------------
	-- Cast Essential Buffs
	ccrCastBuffIfMissing("Lightning Shield")
	if GetWeaponEnchantInfo() == nil then ccrCast("Flametongue Weapon") end
	--------------------------
	-- Autoaccept LFR invite
	AcceptProposal();
	--------------------------

		-- Wait until casting is over 
			-- Lava Burst
			if SpellIsReady("Lava Burst")
				and ccrPlayerHasBuff("Ascendance")
				and ccrTargetHasMyDebuff("Flame Shock")
					then
						ccrCastAttack("Lava Burst")
					return
			end
		if ccrPlayerIsCastingOrChanneling() then return end
		-- Healing 
			if vGotConductivity then
				-- Healing Rain
				if SpellIsReady("Healing Rain")
				and not ccrPlayerHasBuff("Healing Rain")
				and (ccrPlayerHasBuff("Spiritwalker's Grace") or not ccrPlayerIsMoving())
				then
					if #tblGroupedPlayersHealth > 1 then
						ccrCast("Healing Rain")
						if SpellIsTargeting() == 1 then CastAtLocation(GetAveragePositionOfObjects(tblGroupedPlayersHealth)) end
						return
					end
				end
			end

		-- CD's in combat
			if ccrTargetIsBoss() 
			and SpellIsReady("Fire Elemental Totem")
			and ccrTargetHasMyDebuff("Flame Shock")
				then
					ccrCast("Fire Elemental Totem")
					return
			end
			if ccrPlayerHasBuff("Ascendance")
			and SpellIsReady("Spiritwalker's Grace")
				then
					ccrCast("Spiritwalker's Grace")
					return
			end
			if ccrTargetIsBoss() 
			and SpellIsReady("Ascendance")
			and HasActiveTotem()
			and ccrTargetHasMyDebuff("Flame Shock")
				then
					ccrCast("Ascendance")
					return
			end
		if IsMounted() == nil and ccrPlayerIsInCombat() then
			-- Chain Lightning AOE
			if ccrTargetCount(10) >= 3
				then
					ccrCastAttack("Chain Lightning")
				return
			end
			-- Lava Burst
			if SpellIsReady("Lava Burst")
				and ccrTargetHasMyDebuff("Flame Shock")
					then
						ccrCastAttack("Lava Burst")
					return
			end
			-- Flame Shock Boss 1 - 3
			-- Flame Shock
			if not ccrTargetHasMyDebuff("Flame Shock")
				then
					ccrCastAttack("Flame Shock")
				return
			end
			-- Elemental Blast
			if SpellIsReady("Elemental Blast")
				and not ccrPlayerHasBuff("Ascendance")
				then
					ccrCastAttack("Elemental Blast")
				return
			end
			-- Earth Shock
			if ccrPlayerHasBuffStacks("Lightning Shield", 7)
				and SpellIsReady("Earth Shock")
				and not ccrPlayerHasBuff("Ascendance")
					then
						ccrCastAttack("Earth Shock")
					return
			end
			-- Searing Totem
			if not HasActiveTotem()
				then
					ccrCastAttack("Searing Totem")
				return
			end
			-- Chain Lightning as filler if 2 targets
			if ccrTargetCount(10) >= 2
				then
					ccrCastAttack("Chain Lightning")
				return
			end
			-- Lightning Bolt
			if SpellIsReady("Lightning Bolt")
				and not ccrPlayerHasBuff("Ascendance")
				then
					ccrCastAttack("Lightning Bolt")
				return
			end
		end	
end		

